﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Assignment2
{
    class GamepadHandler
    {
        private static GamePadState gamePad;
        private static GamePadState oldGamePad;


        private static int countA = 0;
        public static int CountA { get { return countA; } }

        //init gamepad state
        public static void InitGamepad()
        {
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                gamePad = GamePad.GetState(PlayerIndex.One);
            }
        }

        //listen to A button
        public static void ButtonAListener()
        {
            if (gamePad.IsButtonDown(Buttons.A) && oldGamePad.IsButtonUp(Buttons.A))
            {
                countA += 1;
            }
            oldGamePad = gamePad;
        }

        //listen to left thumstick move
        public static void GamePadMoveListener(ref Vector2 stringPos)
        {
            stringPos += gamePad.ThumbSticks.Left * 5;
        }

    }
}
